home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / labyrunr.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  10KB  |  304 lines

  1. /***************************************************************************
  2.  
  3. Labyrinth Runner (GX771) (c) 1987 Konami
  4.  
  5. similar to Fast Lane
  6.  
  7. Driver by Nicola Salmoria
  8.  
  9. ***************************************************************************/
  10.  
  11. #include "driver.h"
  12. #include "cpu/m6809/m6809.h"
  13. #include "vidhrdw/generic.h"
  14. #include "vidhrdw/konamiic.h"
  15.  
  16.  
  17.  
  18. /* from vidhrdw/labyrunr.c */
  19. extern unsigned char *labyrunr_videoram1,*labyrunr_videoram2;
  20. void labyrunr_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  21. WRITE_HANDLER( labyrunr_vram1_w );
  22. WRITE_HANDLER( labyrunr_vram2_w );
  23. int labyrunr_vh_start(void);
  24. void labyrunr_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  25.  
  26. static int labyrunr_interrupt(void)
  27. {
  28.     if (cpu_getiloops() == 0)
  29.     {
  30.         if (K007121_ctrlram[0][0x07] & 0x02) return HD6309_INT_IRQ;
  31.     }
  32.     else if (cpu_getiloops() % 2)
  33.     {
  34.         if (K007121_ctrlram[0][0x07] & 0x01) return nmi_interrupt();
  35.     }
  36.     return ignore_interrupt();
  37. }
  38.  
  39. static WRITE_HANDLER( labyrunr_bankswitch_w )
  40. {
  41.     int bankaddress;
  42.     unsigned char *RAM = memory_region(REGION_CPU1);
  43.  
  44. if (data & 0xe0) usrintf_showmessage("bankswitch %02x",data);
  45.  
  46.     /* bits 0-2 = bank number */
  47.     bankaddress = 0x10000 + (data & 0x07) * 0x4000;
  48.     cpu_setbank(1,&RAM[bankaddress]);
  49.  
  50.     /* bits 3 and 4 are coin counters */
  51.     coin_counter_w(0,data & 0x08);
  52.     coin_counter_w(1,data & 0x10);
  53. }
  54.  
  55. static struct MemoryReadAddress labyrunr_readmem[] =
  56. {
  57.     { 0x0020, 0x005f, MRA_RAM },    /* scroll registers */
  58.     { 0x0801, 0x0801, YM2203_status_port_0_r },
  59.     { 0x0800, 0x0800, YM2203_read_port_0_r },
  60.     { 0x0901, 0x0901, YM2203_status_port_1_r },
  61.     { 0x0900, 0x0900, YM2203_read_port_1_r },
  62.     { 0x0a00, 0x0a00, input_port_5_r },
  63.     { 0x0a01, 0x0a01, input_port_4_r },
  64.     { 0x0b00, 0x0b00, input_port_3_r },
  65.     { 0x0d00, 0x0d1f, K051733_r },            /* 051733 (protection) */
  66.     { 0x1000, 0x10ff, paletteram_r },
  67.     { 0x1800, 0x1fff, MRA_RAM },
  68.     { 0x2000, 0x3fff, MRA_RAM },
  69.     { 0x4000, 0x7fff, MRA_BANK1 },
  70.     { 0x8000, 0xffff, MRA_ROM },
  71.     { -1 }    /* end of table */
  72. };
  73.  
  74. static struct MemoryWriteAddress labyrunr_writemem[] =
  75. {
  76.     { 0x0000, 0x0007, K007121_ctrl_0_w },
  77.     { 0x0020, 0x005f, MWA_RAM },    /* scroll registers */
  78.     { 0x0801, 0x0801, YM2203_control_port_0_w },
  79.     { 0x0800, 0x0800, YM2203_write_port_0_w },
  80.     { 0x0901, 0x0901, YM2203_control_port_1_w },
  81.     { 0x0900, 0x0900, YM2203_write_port_1_w },
  82.     { 0x0c00, 0x0c00, labyrunr_bankswitch_w },
  83.     { 0x0d00, 0x0d1f, K051733_w },                /* 051733 (protection) */
  84.     { 0x0e00, 0x0e00, watchdog_reset_w },
  85.     { 0x1000, 0x10ff, paletteram_xBBBBBGGGGGRRRRR_swap_w, &paletteram },
  86.     { 0x1800, 0x1fff, MWA_RAM },
  87.     { 0x2000, 0x2fff, MWA_RAM, &spriteram },    /* Sprite RAM */
  88.     { 0x3000, 0x37ff, labyrunr_vram1_w, &labyrunr_videoram1 },
  89.     { 0x3800, 0x3fff, labyrunr_vram2_w, &labyrunr_videoram2 },
  90.     { 0x4000, 0xffff, MWA_ROM },
  91.     { -1 }    /* end of table */
  92. };
  93.  
  94.  
  95. /***************************************************************************
  96.  
  97.     Input Ports
  98.  
  99. ***************************************************************************/
  100.  
  101. INPUT_PORTS_START( labyrunr )
  102.     PORT_START    /* DSW #1 */
  103.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  104.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  105.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  106.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  107.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  108.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  109.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  110.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  111.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  112.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  113.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  114.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  115.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  116.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  117.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  118.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  119.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  120.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  121.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  122.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  123.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  124.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  125.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  126.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  127.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  128.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  129.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  130.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  131.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  132.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  133.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  134.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  135.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  136. //    PORT_DIPSETTING(    0x00, "Invalid" )
  137.  
  138.     PORT_START    /* DSW #2 */
  139.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
  140.     PORT_DIPSETTING(    0x03, "2" )
  141.     PORT_DIPSETTING(    0x02, "3" )
  142.     PORT_DIPSETTING(    0x01, "5" )
  143.     PORT_DIPSETTING(    0x00, "7" )
  144.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  145.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  146.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  147.     PORT_DIPNAME( 0x18, 0x18, DEF_STR( Bonus_Life ) )
  148.     PORT_DIPSETTING(    0x18, "30000 70000" )
  149.     PORT_DIPSETTING(    0x10, "40000 80000" )
  150.     PORT_DIPSETTING(    0x08, "40000" )
  151.     PORT_DIPSETTING(    0x00, "50000" )
  152.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
  153.     PORT_DIPSETTING(    0x60, "Easy" )
  154.     PORT_DIPSETTING(    0x40, "Normal" )
  155.     PORT_DIPSETTING(    0x20, "Hard" )
  156.     PORT_DIPSETTING(    0x00, "Hardest" )
  157.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  158.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  159.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  160.  
  161.     PORT_START    /* DSW #3 */
  162.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  163.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  164.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  165.     PORT_DIPNAME( 0x02, 0x02, "Upright Controls" )
  166.     PORT_DIPSETTING(    0x02, "Single" )
  167.     PORT_DIPSETTING(    0x00, "Dual" )
  168.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  169.     PORT_DIPNAME( 0x08, 0x08, "Continues" )
  170.     PORT_DIPSETTING(    0x08, "3" )
  171.     PORT_DIPSETTING(    0x00, "5" )
  172.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  173.  
  174.     PORT_START    /* COINSW */
  175.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  176.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  177.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
  178.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  179.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  180.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  181.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  182.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  183.  
  184.     PORT_START    /* PLAYER 1 INPUTS */
  185.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  186.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  187.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  188.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  189.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  190.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  191.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  192.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  193.  
  194.     PORT_START    /* PLAYER 2 INPUTS */
  195.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_COCKTAIL )
  196.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  197.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_COCKTAIL )
  198.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_COCKTAIL )
  199.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  200.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  201.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  202.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  203. INPUT_PORTS_END
  204.  
  205.  
  206.  
  207. static struct GfxLayout gfxlayout =
  208. {
  209.     8,8,
  210.     0x40000/32,
  211.     4,
  212.     { 0, 1, 2, 3 },
  213.     { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 },
  214.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  215.     32*8
  216. };
  217.  
  218. static struct GfxDecodeInfo gfxdecodeinfo[] =
  219. {
  220.     { REGION_GFX1, 0, &gfxlayout, 0, 8*16 },
  221.     { -1 } /* end of array */
  222. };
  223.  
  224. /***************************************************************************
  225.  
  226.     Machine Driver
  227.  
  228. ***************************************************************************/
  229.  
  230. static struct YM2203interface ym2203_interface =
  231. {
  232.     2,            /* 2 chips */
  233.     3000000,    /* 24MHz/8? */
  234.     { YM2203_VOL(80,40), YM2203_VOL(80,40) },
  235.     { input_port_0_r },
  236.     { input_port_1_r, input_port_2_r },
  237.     { 0 },
  238.     { 0 }
  239. };
  240.  
  241.  
  242.  
  243. static struct MachineDriver machine_driver_labyrunr =
  244. {
  245.     /* basic machine hardware */
  246.     {
  247.         {
  248.             CPU_HD6309,
  249.             3000000,        /* 24MHz/8? */
  250.             labyrunr_readmem,labyrunr_writemem,0,0,
  251.             labyrunr_interrupt,8    /* 1 IRQ + 4 NMI (generated by 007121) */
  252.         }
  253.     },
  254.     60, DEFAULT_60HZ_VBLANK_DURATION,
  255.     1,
  256.     0,
  257.  
  258.     /* video hardware */
  259.     37*8, 32*8, { 0*8, 35*8-1, 2*8, 30*8-1 },
  260.     gfxdecodeinfo,
  261.     128, 2*8*16*16,
  262.     labyrunr_vh_convert_color_prom,
  263.  
  264.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  265.     0,
  266.     labyrunr_vh_start,
  267.     0,
  268.     labyrunr_vh_screenrefresh,
  269.  
  270.     /* sound hardware */
  271.     0,0,0,0,
  272.     {
  273.         {
  274.             SOUND_YM2203,
  275.             &ym2203_interface
  276.         }
  277.     }
  278. };
  279.  
  280.  
  281. /***************************************************************************
  282.  
  283.   Game ROMs
  284.  
  285. ***************************************************************************/
  286.  
  287. ROM_START( labyrunr )
  288.     ROM_REGION( 0x28000, REGION_CPU1 ) /* code + banked roms */
  289.     ROM_LOAD( "771j04.10f", 0x10000, 0x08000, 0x354a41d0 )
  290.     ROM_CONTINUE(           0x08000, 0x08000 )
  291.     ROM_LOAD( "771j03.08f", 0x18000, 0x10000, 0x12b49044 )
  292.  
  293.     ROM_REGION( 0x40000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  294.     ROM_LOAD( "771d01.14a",    0x00000, 0x40000, 0x15c8f5f9 )    /* tiles + sprites */
  295.  
  296.     ROM_REGION( 0x0100, REGION_PROMS )
  297.     ROM_LOAD( "771d02.08d", 0x0000, 0x0100, 0x3d34bb5a )    /* sprite lookup table */
  298.                                                             /* there is no char lookup table */
  299. ROM_END
  300.  
  301.  
  302.  
  303. GAMEX( 1987, labyrunr, 0, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (Japan)", GAME_NOT_WORKING )
  304.